from fastapi import APIRouter, Depends , HTTPException

from model.user import User , UserInDB 
from data import user as db 
from error import Missing, Duplicate 

router = APIRouter(prefix='/user') 

@router.post('/') 
async def create(user: UserInDB): 
    try:
       return db.create(user) 
    except Duplicate as e: 
        raise HTTPException(status_code=404, detail=e.msg)
    
